import Cookies from 'js-cookie'

const TokenKey = 'Admin-Token'

export function getToken() {
  return Cookies.get(TokenKey)
}

export function setToken(token) {
  return Cookies.set(TokenKey, token)
}

//t单位为毫秒，
export function setTokenOfTime(token,t) {
  //return Cookies.set(TokenKey, token)

  // 设置半小时后失效的 cookie
  const now = new Date();
  const expiryTime = new Date(now.getTime() + t); 
  return Cookies.set(TokenKey, token, { expires: expiryTime }); 
}

export function removeToken() {
  return Cookies.remove(TokenKey)
}
